package com.gzhryc.common;

import org.apache.commons.lang3.StringUtils;

public class StringPositionUtils {

	public static String getEmpty(Integer length) {
		StringBuffer sb = new StringBuffer();
		for(int i =0;i<length;i++) {
			sb.append("0");
		}
		return sb.toString();
	}
	
	public static boolean isTrue(String powerStr,Integer index) {
		if(StringUtils.isNotBlank(powerStr) && index != null) {
			if(powerStr.length() >= index) {
				char[] charArr = powerStr.toCharArray();
				if(charArr[index] == '1') {
					return true;
				}
			}
		}
		return false;
	}
	
	public static String setTrue(String powerStr,Integer index) {
		if(StringUtils.isNotBlank(powerStr) && index != null) {
			if(powerStr.length() >= index) {
				char[] charArr = powerStr.toCharArray();
				charArr[index] = '1';
				return String.valueOf(charArr);
			}
		}
		return null;
	}
	
	public static String setFalse(String powerStr,Integer index) {
		if(StringUtils.isNotBlank(powerStr) && index != null) {
			if(powerStr.length() >= index) {
				char[] charArr = powerStr.toCharArray();
				charArr[index] = '0';
				return String.valueOf(charArr);
			}
		}
		return null;
	}

}
